package com.song.tools.songtest.controller;

import com.song.tools.core.beans.response.ResultVo;
import com.song.tools.mvc.request.IdRequest;
import com.song.tools.mvc.request.PageRequest;
import com.song.tools.mvc.response.PageResponse;
import com.song.tools.songtest.beans.request.SystemLogQueryRequest;
import com.song.tools.songtest.beans.response.SystemLogQueryResponse;
import com.song.tools.songtest.service.SystemLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * <p>
 * 系统日志表 前端控制器
 * </p>
 *
 * @author song tools
 * @since 2024-07-16
 */
@Tag(name = "系统日志表前端控制器")
@RestController
@RequestMapping("/systemLog")
public class SystemLogController {

    @Resource
    private SystemLogService systemLogService;

    /**
     * 分页查询
     *
     * @param request 请求
     * @return 分页响应
     */
    @Operation(summary = "分页查询")
    @PostMapping("/listPages")
    public ResultVo<PageResponse<SystemLogQueryResponse>> listPages(@Valid @RequestBody PageRequest<SystemLogQueryRequest> request) {
        request.defaultPage();
        return ResultVo.success(systemLogService.listPages(request));
    }


    /**
     * 查询详细信息
     *
     * @param request 请求
     * @return 响应
     */
    @PostMapping(value = "/getDetail")
    @Operation(summary = "查询详细信息")
    public ResultVo<SystemLogQueryResponse> getDetail(@Valid @RequestBody IdRequest<Long> request) {
        return ResultVo.success(systemLogService.getOneByUniqueKey(request.getId(), request.getIdFieldName()));
    }
}
